package com.us.core;

import javax.servlet.http.HttpServletRequest;

import com.us.vo.User;

public class UserAction {

    // 当前用户登录的key
    public static final String USER_SESSION_KEY = "loginUser";

    private static HttpServletRequest request = null;

    public static void remember(final User user) {
        request.getSession().setAttribute(USER_SESSION_KEY, user);
    }

    public static void logout() {
        request.getSession().removeAttribute(USER_SESSION_KEY);
    }

    public static User curentUser() {
        return curUser(request);
    }

    public static User curUser(HttpServletRequest request) {
        if (request == null) {
            return null;
        }
        return (User) request.getSession().getAttribute(USER_SESSION_KEY);
    }
}
